/* 全局样式重置 - 彻底消除白边 */
html, body {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    /* 移动端优化 - 防止滚动和缩放 */
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
    /* 防止iOS Safari的弹性滚动 */
    overscroll-behavior: none;
    -webkit-overscroll-behavior: none;
}

/* 横屏提示样式 */
.orientation-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.orientation-content {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.phone-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.rotate-hint {
    font-size: 40px;
    margin-top: 20px;
    animation: rotate 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(90deg); }
    75% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* UI1: 玩家信息设置页面 */
.player-setup-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.setup-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.author-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.author-info p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.game-title {
    text-align: center;
    margin-bottom: 30px;
}

.game-title h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 0;
}

.character-selection {
    margin-bottom: 30px;
}

.character-selection h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.avatar-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.avatar-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-5px);
}

.avatar-option.selected {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.avatar-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.avatar-option span {
    display: block;
    font-size: 0.9rem;
    font-weight: bold;
}

.name-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    align-items: center;
}

#nameInput {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#nameInput:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
}

#nameInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#randomNameBtn {
    padding: 12px 25px;
    background: rgba(255, 193, 7, 0.8);
    border: none;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#randomNameBtn:hover {
    background: rgba(255, 193, 7, 1);
    transform: scale(1.05);
}

.start-game-btn {
    width: 100%;
    max-width: 300px;
    padding: 18px 30px;
    background: linear-gradient(45deg, #4CAF50, #45a049);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 auto;
    display: block;
    box-shadow: 0 10px 20px rgba(76, 175, 80, 0.3);
}

.start-game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(76, 175, 80, 0.4);
}

.game-rules {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
}

.game-rules h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #FFD700;
}

.game-rules ul {
    list-style: none;
    line-height: 1.8;
}

.game-rules li {
    margin-bottom: 8px;
    padding-left: 10px;
}

/* UI2: 游戏界面 */
.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    /* 消除白边的额外设置 */
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    overflow: hidden;
    /* 确保在所有设备上完全覆盖 */
    min-width: 100vw;
    min-height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
}

#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background: #2c3e50;
    display: block;
    pointer-events: none;
    /* 消除白边的关键设置 */
    object-fit: cover;
    object-position: center;
    border: none;
    outline: none;
    margin: 0;
    padding: 0;
}

#gameCanvas.game-active {
    pointer-events: auto;
    cursor: none;
}

/* 游戏进行时UI组件的透明度控制 */
.game-container.playing .player-info-panel,
.game-container.playing .leaderboard-panel,
.game-container.playing .virtual-keypad {
    opacity: 0.6;
}

.game-container.playing .player-info-panel:hover,
.game-container.playing .leaderboard-panel:hover,
.game-container.playing .virtual-keypad:hover {
    opacity: 1;
}

/* 移动端响应式优化 - 标准移动设备 */
@media (max-width: 768px) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.3;
    }
    
    .game-container.playing .virtual-keypad {
        opacity: 0.7;
    }
    
    /* 移动端UI组件尺寸优化 - 基于视口宽度缩放 */
    .player-info-panel {
        top: 12px;
        left: 12px;
        padding: 10px 15px;
        min-width: 160px;
        font-size: 12px;
        transform: scale(0.85);
        transform-origin: top left;
        max-width: 200px;
    }
    
    .leaderboard-panel {
        top: 12px;
        right: 12px;
        padding: 10px 12px;
        min-width: 180px;
        max-height: 300px;
        font-size: 12px;
        transform: scale(0.85);
        transform-origin: top right;
        max-width: 220px;
    }
    
    .leaderboard-item {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    /* 虚拟键盘整体容器缩放 - 修复背景不缩放问题 */
    .virtual-controls-panel {
        transform: scale(0.75);
        transform-origin: bottom right;
        bottom: 15px;
        right: 15px;
    }
    
    .virtual-keypad {
        bottom: 0;
        right: 0;
        padding: 15px;
        /* 移除单独的transform，使用容器的transform */
    }
    
    .virtual-keypad .keypad-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* 地图组件大幅缩放 */
    .minimap {
        transform: scale(0.6);
        transform-origin: bottom left;
    }
}

/* iPhone 16 Pro等超高分辨率设备优化 (393x852, 3x pixel ratio) */
@media (max-width: 430px) and (-webkit-min-device-pixel-ratio: 3) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.6;
    }
    
    .game-container.playing .virtual-controls-panel {
        opacity: 0.8;
    }
    
    .player-info-panel {
        top: 10px;
        left: 10px;
        padding: 10px 15px;
        min-width: 160px;
        font-size: 12px;
        transform: scale(0.7);
        transform-origin: top left;
        max-width: 200px;
    }
    
    .leaderboard-panel {
        top: 10px;
        right: 10px;
        padding: 10px 12px;
        min-width: 180px;
        max-height: 280px;
        font-size: 12px;
        transform: scale(0.7);
        transform-origin: top right;
        max-width: 220px;
    }
    
    .leaderboard-item {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    /* 虚拟键盘容器整体缩放 - 确保背景也缩放 */
    .virtual-controls-panel {
        transform: scale(0.6);
        transform-origin: bottom right;
        bottom: 15px;
        right: 15px;
    }
    
    /* 地图组件最小化 */
    .minimap {
        transform: scale(0.4);
        transform-origin: bottom left;
    }
}

/* 高分辨率移动设备优化 (其他设备) */
@media (max-width: 480px) and (-webkit-min-device-pixel-ratio: 2) and (-webkit-max-device-pixel-ratio: 2.9) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.6;
    }
    
    .game-container.playing .virtual-controls-panel {
        opacity: 0.8;
    }
    
    .player-info-panel {
        top: 10px;
        left: 10px;
        padding: 10px 15px;
        min-width: 160px;
        font-size: 12px;
        transform: scale(0.75);
        transform-origin: top left;
        max-width: 200px;
    }
    
    .leaderboard-panel {
        top: 10px;
        right: 10px;
        padding: 10px 12px;
        min-width: 180px;
        max-height: 250px;
        font-size: 12px;
        transform: scale(0.75);
        transform-origin: top right;
        max-width: 220px;
    }
    
    .leaderboard-item {
        padding: 5px 8px;
        font-size: 11px;
    }
    
    /* 虚拟键盘容器缩放 */
    .virtual-controls-panel {
        transform: scale(0.65);
        transform-origin: bottom right;
        bottom: 10px;
        right: 10px;
    }
    
    /* 地图组件缩放 */
    .minimap {
        transform: scale(0.5);
        transform-origin: bottom left;
    }
}

/* 标准小屏幕设备优化 */
@media (max-width: 480px) and (-webkit-max-device-pixel-ratio: 1.9) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.6;
    }
    
    .game-container.playing .virtual-keypad {
        opacity: 0.8;
    }
    
    .player-info-panel {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        min-width: 140px;
        font-size: 11px;
        transform: scale(0.8);
        transform-origin: top left;
        max-width: 180px;
    }
    
    .leaderboard-panel {
        top: 10px;
        right: 10px;
        padding: 8px 10px;
        min-width: 160px;
        max-height: 220px;
        font-size: 11px;
        transform: scale(0.8);
        transform-origin: top right;
        max-width: 200px;
    }
    
    .leaderboard-item {
        padding: 4px 6px;
        font-size: 10px;
    }
    
    /* 虚拟键盘容器缩放 */
    .virtual-controls-panel {
        transform: scale(0.7);
        transform-origin: bottom right;
        bottom: 12px;
        right: 12px;
    }
    
    .virtual-keypad {
        bottom: 0;
        right: 0;
        padding: 15px;
    }
    
    .virtual-keypad .keypad-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* 地图组件缩放 */
    .minimap {
        transform: scale(0.3);
        transform-origin: bottom left;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.2;
    }
    
    .game-container.playing .virtual-keypad {
        opacity: 0.5;
    }
    
    .player-info-panel {
        top: 0.3vh;
        left: 0.3vh;
        padding: 0.8vh;
        font-size: 1.8vh;
        transform: scale(0.55);
        transform-origin: top left;
        min-width: 15vw;
        max-width: 20vw;
    }
    
    .leaderboard-panel {
        top: 0.3vh;
        right: 0.3vh;
        padding: 0.8vh;
        max-height: 25vh;
        font-size: 1.8vh;
        transform: scale(0.55);
        transform-origin: top right;
        min-width: 18vw;
        max-width: 25vw;
    }
    
    .virtual-keypad {
        bottom: 0.8vh;
        right: 0.8vh;
        padding: 0.8vh;
        transform: scale(0.4);
        transform-origin: bottom right;
    }
    
    .virtual-keypad .keypad-button {
        width: 5vh;
        height: 5vh;
        font-size: 2vh;
    }
    
    /* 横屏时地图组件缩放 */
    .minimap {
        transform: scale(0.3);
        transform-origin: bottom left;
    }
}

/* 平板端优化 */
@media (min-width: 769px) and (max-width: 1023px) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.35;
    }
    
    .game-container.playing .virtual-keypad {
        opacity: 0.75;
    }
    
    .player-info-panel {
        top: 12px;
        left: 12px;
        padding: 12px;
        min-width: 180px;
        font-size: 13px;
        transform: scale(0.9);
        max-width: 220px;
    }
    
    .leaderboard-panel {
        top: 12px;
        right: 12px;
        padding: 12px;
        min-width: 200px;
        max-height: 350px;
        font-size: 13px;
        transform: scale(0.9);
        max-width: 250px;
    }
    
    .virtual-keypad {
        bottom: 15px;
        right: 15px;
        padding: 12px;
        transform: scale(0.75);
        transform-origin: bottom right;
    }
    
    .virtual-keypad .keypad-button {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    
    .minimap {
        transform: scale(0.65);
        transform-origin: bottom left;
    }
    
    .leaderboard-item {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* PC端优化 */
@media (min-width: 1024px) {
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.4;
    }
    
    .game-container.playing .virtual-keypad {
        opacity: 0.8;
    }
    
    .player-info-panel {
        top: 15px;
        left: 15px;
        padding: 15px;
        min-width: 200px;
        font-size: 14px;
        transform: scale(1);
        max-width: 250px;
    }
    
    .leaderboard-panel {
        top: 15px;
        right: 15px;
        padding: 15px;
        min-width: 220px;
        max-height: 400px;
        font-size: 14px;
        transform: scale(1);
        max-width: 280px;
    }
    
    .virtual-keypad {
        bottom: 20px;
        right: 20px;
        padding: 15px;
        transform: scale(0.9);
        transform-origin: bottom right;
    }
    
    .virtual-keypad .keypad-button {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .minimap {
        transform: scale(0.8);
        transform-origin: bottom left;
    }
    
    .leaderboard-item {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* 游戏UI面板通用样式 */
.game-ui-panel {
    position: fixed;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    z-index: 200;
    transition: all 0.3s ease;
}

.game-ui-panel:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 左上角：玩家信息面板 */
.player-info-panel {
    top: 20px;
    left: 20px;
    padding: 15px 20px;
    min-width: 250px;
}

.panel-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-avatar {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.player-details {
    flex: 1;
}

.player-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: #4CAF50;
}

.player-stats {
    display: flex;
    gap: 15px;
}

.stat-item {
    font-size: 0.9rem;
    font-weight: bold;
}

.connection-indicator {
    margin-top: 10px;
    text-align: center;
    padding: 5px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.status-connected {
    color: #4CAF50;
}

.status-disconnected {
    color: #f44336;
}

/* 世界消息面板 */
/* 顶部消息提示样式 */
.top-message-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    max-width: 600px;
    width: 90%;
    pointer-events: none;
}

.message-content {
    background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 8px 32px rgba(255, 107, 53, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    animation: topMessageSlideIn 0.5s ease-out;
}

.message-content::before {
    content: "🎉";
    margin-right: 10px;
    font-size: 1.2em;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes topMessageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 右上角：排行榜面板 */
.leaderboard-panel {
    top: 20px;
    right: 20px;
    width: 280px;
    max-height: 400px;
    padding: 15px;
}

.panel-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

#leaderboardList {
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-item.current-player {
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.player-rank {
    font-weight: bold;
    color: #FFD700;
    margin-right: 10px;
    min-width: 25px;
}

.player-name {
    flex: 1;
    text-align: left;
}

.player-score {
    font-weight: bold;
    color: #4CAF50;
}

/* 右下角：虚拟键盘面板 */
.virtual-controls-panel {
    bottom: 20px;
    right: 20px;
    padding: 15px;
}

.virtual-keypad {
    display: grid;
    gap: 8px;
}

.keypad-row {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.virtual-key {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.virtual-key:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.virtual-key.active {
    background: rgba(76, 175, 80, 0.4);
    border-color: #4CAF50;
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.center-key {
    background: transparent;
    border: none;
    cursor: default;
}

.center-key:hover {
    background: transparent;
    transform: none;
}

/* 游戏结束覆盖层 */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.death-screen {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.death-screen h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #ff6b6b;
}

.death-message {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.final-stats {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.final-stats p {
    margin: 8px 0;
    font-size: 1.1rem;
}

.respawn-btn, .back-btn {
    padding: 15px 30px;
    margin: 10px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.respawn-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
}

.back-btn {
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
}

.respawn-btn:hover, .back-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .setup-container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-title h1 {
        font-size: 2rem;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .avatar-option {
        padding: 15px 8px;
    }
    
    .avatar-icon {
        font-size: 2rem;
    }
    
    .player-info-panel {
        top: 10px;
        left: 10px;
        right: 10px;
        min-width: auto;
        padding: 10px 15px;
    }
    
    .leaderboard-panel {
        top: 80px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 200px;
    }
    
    .virtual-controls-panel {
        bottom: 10px;
        right: 10px;
    }
    
    .virtual-key {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* 移动端竖屏时显示横屏提示 */
@media (max-width: 768px) and (orientation: portrait) {
    .orientation-prompt {
        display: flex;
    }
    
    .player-setup-screen,
    .game-container {
        display: none;
    }
}

/* 移动端横屏时隐藏提示 */
@media (max-width: 768px) and (orientation: landscape) {
    .orientation-prompt {
        display: none;
    }
    
    .player-info-panel {
        top: 5px;
        left: 5px;
        padding: 8px 12px;
        min-width: 200px;
    }
    
    .leaderboard-panel {
        top: 5px;
        right: 5px;
        width: 200px;
        max-height: 150px;
        padding: 10px;
    }
    
    .virtual-controls-panel {
        bottom: 5px;
        right: 5px;
        padding: 10px;
    }
    
    .virtual-key {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* 桌面端和移动端显示控制 */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-ui-panel {
    animation: fadeIn 0.5s ease-out;
}

/* iPhone 16 Pro 专门优化 (402x874 视口) */
@media (max-width: 430px) and (max-height: 932px) and (-webkit-min-device-pixel-ratio: 3) {
    /* 游戏容器全屏优化 */
    .game-container {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    
    /* 画布居中显示，保持合适比例 */
    #gameCanvas {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 100vw;
        max-height: 100vh;
        width: auto;
        height: auto;
    }
    
    /* 玩家信息面板 - 左上角紧凑布局 */
    .player-info-panel {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        min-width: 140px;
        max-width: 180px;
        font-size: 11px;
        transform: scale(0.4);
        transform-origin: top left;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(10px);
    }
    
    .player-avatar {
        font-size: 1.8rem;
        width: 40px;
        height: 40px;
    }
    
    .player-name {
        font-size: 1rem;
        margin-bottom: 4px;
    }
    
    .stat-item {
        font-size: 0.8rem;
    }
    
    /* 排行榜面板 - 右上角优化 */
    .leaderboard-panel {
        top: 10px;
        right: 10px;
        padding: 8px 10px;
        min-width: 160px;
        max-width: 200px;
        max-height: 200px;
        font-size: 10px;
        transform: scale(0.4);
        transform-origin: top right;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(10px);
    }
    
    .leaderboard-item {
        padding: 4px 6px;
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    /* 虚拟控制面板 - 右下角优化 */
    .virtual-controls-panel {
        bottom: 20px;
        right: 20px;
        transform: scale(0.7);
        transform-origin: bottom right;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 15px;
        padding: 10px;
    }
    
    .virtual-keypad {
        bottom: 0;
        right: 0;
        padding: 8px;
    }
    
    .keypad-button {
        width: 45px;
        height: 45px;
        font-size: 16px;
        margin: 2px;
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 8px;
        color: white;
        font-weight: bold;
    }
    
    .keypad-button:active {
        background: rgba(255, 255, 255, 0.4);
        transform: scale(0.95);
    }
    
    /* 小地图优化 */
    .minimap {
        transform: scale(0.6);
        transform-origin: bottom left;
        bottom: 10px;
        left: 10px;
    }
    
    /* 顶部消息通知优化 */
    .top-message-notification {
        top: 15px;
        max-width: 90vw;
        width: 90%;
    }
    
    .message-content {
        padding: 10px 20px;
        font-size: 0.9rem;
        border-radius: 20px;
    }
    
    /* 游戏时透明度调整 */
    .game-container.playing .player-info-panel,
    .game-container.playing .leaderboard-panel {
        opacity: 0.7;
    }
    
    .game-container.playing .virtual-controls-panel {
        opacity: 0.8;
    }
    
    /* 悬停时显示完整内容 */
    .game-container.playing .player-info-panel:hover,
    .game-container.playing .leaderboard-panel:hover,
    .game-container.playing .virtual-controls-panel:hover {
        opacity: 1;
    }
}

/* 加载状态 */
.loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    padding: 20px;
}